/**
 * Copyright (c) 2006 Amgad S Youssef
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 */
package org.eclipsejcde.jctools.options;

import java.util.ArrayList;

import org.eclipsejcde.core.preferences.JCPreferences;

/**
 * @author Amgad S Youssef
 *
 */
public class OptionsPreparer {
	public static String[] prepareConverterOptions() {
		ArrayList<String> optionsList = new ArrayList<String>();
		if (JCPreferences.isCONVERTER_CL_OPTIONS_debug()) {
			optionsList.add("-debug");
		}
		if (JCPreferences.isCONVERTER_CL_OPTIONS_exportmap()) {
			optionsList.add("-exportmap");
		}
		if (JCPreferences.isCONVERTER_CL_OPTIONS_i()) {
			optionsList.add("-i");
		}
		if (JCPreferences.isCONVERTER_CL_OPTIONS_mask()) {
			optionsList.add("-mask");
		}
		if (JCPreferences.isCONVERTER_CL_OPTIONS_nobanner()) {
			optionsList.add("-nobanner");
		}
		if (JCPreferences.isCONVERTER_CL_OPTIONS_noverify()) {
			optionsList.add("-noverify");
		}
		if (JCPreferences.isCONVERTER_CL_OPTIONS_nowarn()) {
			optionsList.add("-nowarn");
		}
		if (JCPreferences.isCONVERTER_CL_OPTIONS_verbose()) {
			optionsList.add("-verbose");
		}

		ArrayList<String> outOptions = new ArrayList<String>();
		if (JCPreferences.isCONVERTER_CL_OPTIONS_out_cap()) {
			outOptions.add("CAP");
		}
		if (JCPreferences.isCONVERTER_CL_OPTIONS_out_exp()) {
			outOptions.add("EXP");
		}
		if (JCPreferences.isCONVERTER_CL_OPTIONS_out_jca()) {
			outOptions.add("JCA");
		}
		
		StringBuffer outOptionsStrBuf = new StringBuffer("-out ");
		if (outOptions.size() > 0) {
			//outOptionsStrBuf.append("-out ");
			for (int i = 0; i < outOptions.size(); i++) {
				outOptionsStrBuf.append(outOptions.get(i));
				if (i < outOptions.size() - 1) {
					outOptionsStrBuf.append(" ");
				}
			}
		}
		
		optionsList.add(outOptionsStrBuf.toString());
		String[] options = new String[optionsList.size()];
		optionsList.toArray(options);
		return options;
	}

	public static String[] prepareCapgenOptions() {
		return new String[] { "" };
	}

	public static String[] prepareVerifycapOptions() {
		return new String[] { "" };
	}

	public static String[] prepareScriptgenOptions() {
		return new String[] { "" };
	}

	public static String[] prepareApdutoolOptions() {
		String[] options = new String[] { "-h localhost", "-p " + JCPreferences.getCREF_CL_OPTIONS_p() };
		return options;
	}

}
